#pragma once

#include "Dynamicobject.h"

class Tank : public DynamicObject
{
public:    

    enum TurnDirectionType
    {
        eTurnLeft,
        eTurnRight
    };

    enum ActionType
    {
        eStaying = 0,
        eMoving,
        eStopping,
        eTurningRight,
        eTurningLeft,
        eUnknown = eStaying
    };
    enum TankType
    {
        PLAYER,
        ENEMY
    };

    Tank();
    Tank(int id, int posX, int posY, CardinalDirection direction, Tank::ActionType action, unsigned progress);

    static qreal AngleFromDirection(CardinalDirection direction);

    virtual unsigned width() const { return 2; }
    virtual unsigned height() const { return 2; }

    void destroy();
    void shoot();
    void move();
    void turn(char direction);
    void render();
    void hit();

    inline qint16 Id() const { return m_id; }
    void SetId(const qint16 id) { m_id = id; }

    inline ActionType CurrentAction() const  {return m_currentAction; }
    inline void SetAction(ActionType action) { m_currentAction = action; }
    inline int Health() const  {return m_healthLvl; }

    inline bool Firing() const { return m_isFiring; }
    inline void SetFiring(bool state) { m_isFiring = state; }

private:
    int m_id;
    int m_healthLvl;
    bool m_isFiring;
    ActionType m_currentAction;
    TankType m_tankType;
};

typedef QSharedPointer<Tank> TankPtr;
